package com.company.JvmDemo;




import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class ASMTest {
    public static void main(String[] args) throws IOException {
        ClassReader classReader = new ClassReader("com.company.JvmDemo.ASMTest$HelloWord");
        ClassWriter classWriter = new ClassWriter(classReader,ClassWriter.COMPUTE_FRAMES);
        ClassVisitor classVisitor = new ClassVisitor(5,classWriter) {
        };
        classReader.accept(classVisitor,0);
        byte[] bytes = classWriter.toByteArray();
        String s = "D:\\桌面\\项目开发\\数据结构和算法\\data-structures-and-algorithms\\src\\com\\company\\JvmDemo";
        Files.write(new File(s).toPath(),bytes);
    }
    public static class HelloWord{
        public void hello(String name){
            int age = 19;
            System.out.println("HelloWord"+age+name);
        }
    }
}

